#!/bin/bash

# Test adding nodes to the gateway only cluster

. ./common

_start_sheep 0 -g
_start_sheep 1 -g
_wait_for_sheep 2

_start_sheep 2
_start_sheep 3
_wait_for_sheep 4

_cluster_format -c 2
for i in 0 1 2 3; do
    $DOG cluster info -p 700$i | _filter_cluster_info
done
$DOG cluster shutdown
_wait_for_sheep_stop

_start_sheep 0 -g
_start_sheep 1 -g
_wait_for_sheep 2

_start_sheep 2
_start_sheep 3
_wait_for_sheep 4
for i in 0 1 2 3; do
    $DOG cluster info -p 700$i | _filter_cluster_info
done

_start_sheep 4
_wait_for_sheep 5
_start_sheep 5
_wait_for_sheep 6
for i in 0 1 2 3 4 5; do
    $DOG cluster info -p 700$i | _filter_cluster_info
done

_kill_sheep 3
_wait_for_sheep 5
_kill_sheep 4
_wait_for_sheep 4
for i in 0 1 2 5; do
    $DOG cluster info -p 700$i | _filter_cluster_info
done
